<template>
  <div class="storeChangeReport">
    <CommonBtn label-name="门店增减变化统计报告" v-if="!button || (button.event!='add()' && button.event!='edit()') " :buttons="buttons" @onButtonClick="onButtonClick">
      <span slot="appendCondition" style="margin-left: 10px">月份：</span>
      <el-date-picker slot="appendCondition"
        type="month" size="mini" v-model="date"
        format="yyyy-MM-dd" value-format="yyyy-MM-dd"
        placeholder="选择日期" ></el-date-picker>
      <span slot="appendCondition" style="margin-left: 10px">类型：</span>
      <el-select slot="appendCondition" v-model="type" size="mini">
        <el-option label="门店类型" value="1"></el-option>
        <el-option label="投资属性" value="2"></el-option>
      </el-select>
    </CommonBtn>
    <CommonList ref="list" v-if="!button || (button.event!='add()' && button.event!='edit()')" :buttons="buttons"
                :columns="columns" :listUrl="listUrl"@tableSelect="tableSelect"  :conditions="conditions"></CommonList>
  </div>
</template>

<script>
    import CommonList from "../../common/CommonList";
    import CommonBtn from "../../common/CommonBtn";
    export default {
        name:'storeChangeReport',
        data(){
            return{
                buttons:[ ],
                columns:[
                    {
                        prop:'typeName',
                        label:'分类'
                    },
                    {
                        prop:'ycmds',
                        label:'月初门店数'
                    },
                    {
                        prop:'xzmds',
                        label:'本月新增门店数'
                    },
                    {
                        prop:'gbmds',
                        label:'本月关闭门店数'
                    },
                    {
                        prop:'tzmds',
                        label:'本月调整门店数'
                    },
                    {
                        prop:'ymmds',
                        label:'月末门店数'
                    }
                ],
                listUrl:this.$api.API_SELECT_RETAILERREPORT_LIST,
                type:'1',
                conditions:[{checked:true,prop:'data',value:''},{checked:true,prop:'type',value:'1'}],
                button:null,
                row:{},
                date:''
            }
        },
        methods:{
            onButtonClick(item) {
                this.button = item
            },
            tableSelect(row) {
                this.row = row
            },
            conditionChange(conditions) {
                this.$refs.list.search()
            }
        },
        watch: {
            date(newVal,oldVal) {
                this.conditions[0].value = newVal
                this.$nextTick(()=>{
                    this.conditionChange()
                })
            },
            type(newVal,oldVal) {
                this.conditions[1].value = newVal
                this.$nextTick(()=>{
                    this.conditionChange()
                })
            }
        },
        components:{CommonList,CommonBtn}
    }
</script>
